package com.yanfan.zutai.service.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.zutai.domain.BDeviceWarnConfig;
import com.yanfan.zutai.mapper.BDeviceWarnConfigMapper;
import com.yanfan.zutai.service.IBDeviceWarnConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 报警配置Service业务层处理
 *
 * @author ruoyi
 * @date 2022-06-01
 */
@Service
public class BDeviceWarnConfigServiceImpl implements IBDeviceWarnConfigService {
    @Autowired
    private BDeviceWarnConfigMapper bDeviceWarnConfigMapper;

    /**
     * 查询报警配置
     *
     * @param id 报警配置主键
     * @return 报警配置
     */
    @Override
    public BDeviceWarnConfig selectBDeviceWarnConfigById(Long id) {
        return bDeviceWarnConfigMapper.selectBDeviceWarnConfigById(id);
    }

    /**
     * 查询报警配置列表
     *
     * @param bDeviceWarnConfig 报警配置
     * @return 报警配置
     */
    @Override
    public List<BDeviceWarnConfig> selectBDeviceWarnConfigList(BDeviceWarnConfig bDeviceWarnConfig) {
        return bDeviceWarnConfigMapper.selectBDeviceWarnConfigList(bDeviceWarnConfig);
    }

    /**
     * 新增报警配置
     *
     * @param bDeviceWarnConfig 报警配置
     * @return 结果
     */
    @Override
    public int insertBDeviceWarnConfig(BDeviceWarnConfig bDeviceWarnConfig) {
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceWarnConfig.setId(id);
        return bDeviceWarnConfigMapper.insertBDeviceWarnConfig(bDeviceWarnConfig);
    }

    /**
     * 修改报警配置
     *
     * @param bDeviceWarnConfig 报警配置
     * @return 结果
     */
    @Override
    public int updateBDeviceWarnConfig(BDeviceWarnConfig bDeviceWarnConfig) {
        return bDeviceWarnConfigMapper.updateBDeviceWarnConfig(bDeviceWarnConfig);
    }

    /**
     * 批量删除报警配置
     *
     * @param ids 需要删除的报警配置主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceWarnConfigByIds(Long[] ids) {
        return bDeviceWarnConfigMapper.deleteBDeviceWarnConfigByIds(ids);
    }

    /**
     * 删除报警配置信息
     *
     * @param id 报警配置主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceWarnConfigById(Long id) {
        return bDeviceWarnConfigMapper.deleteBDeviceWarnConfigById(id);
    }
}
